package com.zfh.controller;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @title:
 * @author: fhzheng
 * @date: 3/15/2021 16:14
 * @description:
 */

public class MyServlet implements Servlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        HttpServletResponse resp = (HttpServletResponse) servletResponse;
        resp.setContentType("text/html;charset=utf-8");
        System.out.println("MyServlet service called.");
        PrintWriter out = resp.getWriter();
        out.print("<h1>MyServlet service called.</h1><r>");
        out.print("<h1>控制直接响应的结果</h1><br>");
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
